{extend name="common/common" /} {block name="style"}
<style type="text/css">
	.container-fluid .btn {
		float: right;
		margin-left: 10px;
	}
	.btn.btn-sm {
		margin: 0;
	}
	.layui-input.layui-unselect {
		width: 150px;
	}
	input[placeholder="部门"]{
			width:200px !important;
	}
	.layui-input-block {
		margin-left: 80px;
	}
	/* #cusTable tr{
		cursor: pointer;
	} */
	.ibox.float-e-margins{
		margin-bottom: 0;
	}
	.chartTips{
		position: absolute;
		left: 40%;
		top: 48%;
		z-index: 999;
	}
	#markShade{
		position: fixed;
		z-index: 9999999999999;
		background-color: #000;
		opacity: 0.3;
		display: none;
		width: 100%;
		height: 100%;
	}
	#markShade h1 {
		color: #FFF;
		text-align: center;
		margin-top:300px;
	}
</style>
{/block} {block name="content"}
<div id="markShade">
	<h1>正在导出</h1>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="ibox float-e-margins">
		<div class="ibox-title">
            <h5>图表工具栏</h5>
        </div>
        <div class="ibox-content">
			<div class="layui-inline">
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="seaTimePic" name="seaTimePic" placeholder="时间范围(默认1个月)">
				</div>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="seaTimeStep" name="seaTimeStep" placeholder="时间步长(默认1天,单位:天)">
				</div>
				<div class="layui-inline">
					<button type="button" id="searchPic" class="btn btn-info" style="margin-top: 2px;">查询</button>
				</div>
			</div>
        </div>
	</div>
	<div class="layui-col-md6" style="padding:5px;">
        <div class="ibox-title">
            <h5>财务统计条形图</h5>
        </div>
        <div class="ibox-content" style="overflow:auto;">
			<div class="chartTips">
				图表加载中:Loading...
			</div>
			<div id="LinePic" style="width: 100%;height:300px; min-width:400px;"></div>
        </div>
	</div>
	<div class="layui-col-md6" style="padding:5px;">
        <div class="ibox-title">
            <h5>财务统计饼形图</h5>
        </div>
        <div class="ibox-content"  style="overflow:auto;">
			<div class="chartTips">
				图表加载中:Loading...
			</div>
			<div id="PiePic" style="width: 100%;height:300px; min-width:400px;"></div>
        </div>
	</div>

	<div class="ibox float-e-margins">
		<div class="ibox-title">
			<h5>财务统计表格</h5>
		</div>
		<div class="ibox-content dataTableBox">
			<form class="layui-form" action="" id="seaForm">
				<div class="layui-form-item">
					<div class="layui-input-inline">
						<input type="text" name="seaSn" id="seaSn" placeholder="订单单号/流水单号" class="layui-input">
					</div>
					<div class="layui-input-inline" style="width:100px;">
						<input type="text" name="seaName" id="seaName" placeholder="姓名" class="layui-input">
					</div>
					<div class="layui-input-inline" style="width:150px;">
						<select name="seaName" id="seaSchool" lay-filter="getMajor" >
							<option value="" selected>学校</option>
							{volist name="$CanseeSchool" id="v"}
							<option value="{$v.id}">{$v.name}</option>
							{/volist}
						</select>
					</div>
					<div class="layui-input-inline" style="width:150px;">
						<select name="seaMajor" id="seaMajor">
							<option value="" selected>专业</option>
						</select>
					</div>
					<div class="layui-input-inline" style="width:150px;">
						<select name="seaGrade" id="seaGrade">
							<option value="" selected>层次</option>
							{volist name="$grade_opt" id="v"}
							<option value="{$v.id}">{$v.name}</option>
							{/volist}
						</select>
					</div>

					<div class="layui-input-inline" style="width:100px;">
						<input type="text" name="seaBatch" id="seaBatch" placeholder="批次" class="layui-input">
					</div>

					<!-- samsara 2018-8-1 新增 -->
					<div class="layui-input-inline" style="width:200px;">
							<select name="depart_id" id="depart_id" lay-filter="depart_id" >
									<option value="" selected>部门</option>
									<?=$dep_Arr;?>
							</select>
					</div>
					<div class="layui-input-inline" style="width:150px;">
							<select name="user_id" id="user_id" lay-filter="user_id" >
									<option value="" selected>咨询师</option>
									<?php foreach($departUserArr as $val):?>
											<option value="<?=$val['id']?>"><?=$val['real_name']?></option>>
									<?php endforeach;?>
							</select>
					</div>

					<!-- <div class="layui-input-inline" style="width:100px;">
						<input type="text" name="seaAsker" id="seaAsker" placeholder="咨询师" class="layui-input">
					</div>
					<div class="layui-input-inline" style="width:100px;">
						<input type="text" name="seaAsk_D" id="seaAsk_D" placeholder="咨询师部门" readonly class="layui-input">
						<input type="hidden" name="seaAsk_D_id" id="seaAsk_D_id">
					</div> -->
				</div>
				<div class="layui-form-item">
					<div class="layui-input-inline" style="width:150px;">
						<select name="seaFee" id="seaFee">
							<option value="" selected>费用</option>
							<option value="tuition">学费</option>
							<option value="registration">报名费</option>
							<option value="material_cost">资料费</option>
							<option value="	photo_collection">照片采集费</option>
						</select>
					</div>
					<div class="layui-input-inline" style="width: 150px;">
						<select name="seaSource" id="seaSource">
							<option value="" selected>来源</option>
							<option value="0">学员</option>
							<option value="1">报销</option>
							<option value="2">罚款</option>
							<option value="3">退款</option>
							<option value="4">其他</option>
						</select>
					</div>
					<div class="layui-inline">
						<div class="layui-input-inline">
							<input type="text" class="layui-input" id="seaTime" name="seaTime" placeholder="时间范围">
						</div>
					</div>
					<div class="layui-inline">
						<button type="button" id="search" class="btn btn-info" style="margin-top: 2px;">查询</button>
					</div>
					<div class="layui-inline">
						<button type="button" id="seaTimeDate" class="btn btn-default reportBtns" style="margin-top: 2px;">日报</button>
					</div>
					<div class="layui-inline">
						<button type="button" id="seaTimeWeek" class="btn btn-success reportBtns" style="margin-top: 2px;">周报</button>
					</div>
					<div class="layui-inline">
						<button type="button" id="seaTimeMonth" class="btn btn-success reportBtns" style="margin-top: 2px;">月报</button>
					</div>
					<div class="layui-inline">
						<button type="button" id="seaTimeQuarter" class="btn btn-success reportBtns" style="margin-top: 2px;">季报</button>
					</div>
					<div class="layui-inline">
						<button type="button" id="seaTimeYear" class="btn btn-success reportBtns" style="margin-top: 2px;">年报</button>
					</div>

				</div>
			</form>
			<table id="cusTable">
				<thead>
					<th class="text-center" data-width="100px" data-align="center" data-field="id" data-sortable="true" data-sort-name="id">ID <i class='fa fa-sort' id="fa-id"></i></th>
					<th class="text-center" data-width="200px" data-align="center" data-field="order_sn">订单单号</th>
					<th class="text-center" data-width="150px" data-align="center" data-field="account_sn">流水单号</th>
					<th class="text-center" data-width="100px" data-align="center" data-field="source_name">来源</th>
					<th class="text-center" data-width="100px" data-align="center" data-field="name">学员/报销人</th>
					<th class="text-center" data-width="250px" data-align="center" data-field="from_s">学校/部门</th>
					<th class="text-center" data-width="100px" data-align="center" data-field="grade">层次</th>
					<th class="text-center" data-width="200px" data-align="center" data-field="from_m">专业</th>
					<th class="text-center" data-width="100px" data-align="center" data-field="batch">批次</th>
					<th class="text-center" data-width="100px" data-align="center" data-field="receivables_time" data-sortable="true" data-sort-name="receivables_time">付款时间 <i class='fa fa-sort' id="fa-receivables_time"></i></th>
					<th class="text-center" data-width="100px" data-align="center" data-field="status_name">状态</th>
					<th class="text-center" data-width="100px" data-field="first">咨询师1</th>
					<th class="text-center" data-width="340px" data-field="first_depart">咨询师1部门</th>
					<th class="text-center" data-width="100px" data-field="second">咨询师2</th>
					<th class="text-center" data-width="100px" data-field="second_depart">咨询师2部门</th>
					<th class="text-center" data-width="100px" data-field="pay_type">支付方式</th>
					<th class="text-center" data-width="100px" data-field="origin">生源途径</th>
					<th class="text-center" data-width="100px" data-field="tuition">学费</th>
					<th class="text-center" data-width="100px" data-field="registration">报名费</th>
					<th class="text-center" data-width="100px" data-field="material_cost">资料费</th>
					<th class="text-center" data-width="100px" data-field="photo_collection">照片采集费</th>
					<th class="text-center" data-width="100px" data-field="total_amount_name">总金额</th>
				</thead>
			</table>
		</div>
	</div>

	<!-- <div class="ibox float-e-margins">
		<div class="ibox-title">
			<h5>财务统计总表</h5>
		</div>
		<div class="ibox-content">
			<div class="seaBar">
				<form class="layui-form" action="" id="seaForm2">
				<div class="layui-input-inline" style="width:150px;">
					<select name="seaName" id="seaSchool2" lay-filter="getMajor2" >
						<option value="" selected>学校</option>
						{volist name="$CanseeSchool" id="v"}
						<option value="{$v.id}">{$v.name}</option>
						{/volist}
					</select>
				</div>
				<div class="layui-input-inline" style="width:150px;">
					<select name="seaMajor" id="seaMajor2">
						<option value="" selected>专业</option>
					</select>
				</div>
				<div class="layui-input-inline">
					<select name="seaGrade" id="seaGrade2">
						<option value="" selected>层次</option>
						{volist name="$grade_opt" id="v"}
						<option value="{$v.id}">{$v.name}</option>
						{/volist}
					</select>
				</div>
				<div class="layui-input-inline">
					<input type="text" name="seaBatch" id="seaBatch2" placeholder="批次" class="layui-input">
				</div>
				<div class="layui-inline">
					<div class="layui-input-inline">
						<input type="text" class="layui-input" id="seaTime2" placeholder="年份">
					</div>
				</div>
				<div class="layui-inline">
					<button type="button" id="search2" class="btn btn-info" style="margin-top: 2px;">查询</button>
				</div>
				</form>

				<table id="cusTable2" style="display:none;">
					<thead>
						<th class="text-center" data-align="center" data-field="school_name">学校</th>
						<th class="text-center" data-align="center" data-field="grade">层次</th>
						<th class="text-center" data-align="center" data-field="major_name">专业</th>
						<th class="text-center" data-align="center" data-field="batch">批次</th>
						<th class="text-center" data-align="center" data-field="people_num">人数</th>
						<th class="text-center" data-align="center" data-field="year">年份</th>
						<th class="text-center" data-align="center" data-field="tuition">学费</th>
						<th class="text-center" data-align="center" data-field="registration">报名费</th>
						<th class="text-center" data-align="center" data-field="material_cost">资料费</th>
						<th class="text-center" data-align="center" data-field="photo_collection">照片采集费</th>
						<th class="text-center" data-align="center" data-field="total">金额总额</th>
					</thead>
				</table>
			</div>
		</div>
	</div> -->
</div>
<div class="TreeBox" style="display:none;padding:15px;">
	<div id="tree"></div>
</div>
<!-- <div class="remarksBox" style="display:none;padding:15px;"></div> -->
{/block}

{block name="script"}
<script type="text/javascript" src="__JS__/tableExport.js"></script>
<script type="text/javascript" src="__JS__/bootstrap-table-export.js"></script>
<script type="text/javascript" src="__JS__/getTime.js"></script>
<script type="text/javascript">
	var IDs = '';

	function initTable() {
		//先销毁表格
		$('#cusTable').bootstrapTable('destroy');
		//初始化表格,动态从服务器加载数据
		$("#cusTable").bootstrapTable({
			method: "get", //使用get请求到服务器获取数据
			url: "./accReportList", //获取数据的地址
			striped: true, //表格显示条纹
			pagination: true, //启动分页
			pageSize: 25, //每页显示的记录数
			pageNumber: 1, //当前第几页
			pageList: [25,100,1000,10000,100000], //记录数可选列表
			sidePagination: "server", //表示服务端请求
			resizable:true,
			paginationFirstText: "首页",
			paginationPreText: "上一页",
			paginationNextText: "下一页",
			paginationLastText: "尾页",
			queryParamsType: "undefined",
			silentSort:true,//分页记住排序
			sortName:'receivables_time',
			sortOrder:'desc',
			// showToggle:true,
			showColumns:true,
			showExport: true,  //是否显示导出按钮
			exportTypes:['excel'],  //导出文件类型
			Icons:'glyphicon-export',
			exportOptions:{
				ignoreColumn: [0,1],  //忽略某一列的索引
				fileName: '财务统计表格',  //文件名称设置
				worksheetName: '财务统计表格',  //表格工作区名称
				tableName: '财务统计表格',
				excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
				onMsoNumberFormat:function (cell, row, col) {
			       var result = "";
			       if (row > 0 && col == 0)
			           result = "\\@";
			       return result;
			   }
			},
			detailView:true,// true打开详细模式
			detailFormatter:function(index, row) {
				return "备注:"+row.remarks + "；经办人:" + row.agent_name;
			},
			queryParams: function queryParams(params) { //设置查询参数
				var param = {
					pageNumber: params.pageNumber,
					pageSize: params.pageSize,
					seaSn: $("#seaSn").val(),
					seaName: $("#seaName").val(),
					seaSource: $("#seaSource").val(),
					seaStatus:1,
					seaTime:$("#seaTime").val(),
					seaSchool: $("#seaSchool").val(),
					seaMajor: $("#seaMajor").val(),
					seaGrade: $("#seaGrade").val(),
					seaAsker: $("#user_id").val(),
					seaAsk_D: $("#depart_id").val(),
					seaBatch: $("#seaBatch").val(),
					seaFee: $("#seaFee").val(),

					sortName:this.sortName,
					sortOrder:this.sortOrder,
				};
				return param;
			},
			onLoadSuccess: function(res) { //加载成功时执行
				if (111 == res.code) {
					window.location.reload();
				}
				layer.msg("表格加载成功", {time: 1000});
				var tr = '<tr><td colspan="18" class="text-right span-strong">总计</td>'
					   + '<td class="text-center span-strong">' + res.tuition_sum + '</td>'
					   + '<td class="text-center span-strong">' + res.registration_sum + '</td>'
					   + '<td class="text-center span-strong">' + res.material_cost_sum + '</td>'
					   + '<td class="text-center span-strong">' + res.photo_collection_sum + '</td>'
					   + '<td class="text-center span-strong">' + res.sum + '</td></tr>';
				$("#cusTable tbody").append(tr);
				// var li = "<li data-type='all' onclick='ExportAll();'><a href='javascript:void(0)'>导出全部</a></li>";
				// $(".dataTableBox .dropdown-menu").append(li);
				// var aA = $(".dataTableBox .dropdown-menu li a");
				// for(var i=0;i<aA.length;i++){
				// 	if(aA[i].innerHTML == 'MS-Excel'){
				// 		aA[i].innerHTML = '导出当前';
				// 	}
				// }
				var li = "<li data-type='all' onclick='ExportAll();'><a href='javascript:void(0)'>导出全部</a></li>";
                         $(".dataTableBox .export>.dropdown-menu").append(li);
                         $(".export>.dropdown-menu>li:nth-child(1)>a").html('导出当前');
			},
			onLoadError: function() { //加载失败时执行
				layer.msg("加载数据失败");
			},
			onSort:function(name,order){ //切换排序图标
				var idName = 'fa-' + name;
				var oSort = document.getElementById(idName);
				var oFaId = document.getElementById('fa-id');
				var oFaTm = document.getElementById('fa-receivables_time');
				oFaId.className = 'fa fa-sort';
				oFaTm.className = 'fa fa-sort';
				order == 'asc'?oSort.className = 'fa fa-sort-up':oSort.className = 'fa fa-sort-down';
			}
		});
	}

	// function initTable2() {
	// 	$("#cusTable2").show();
	// 	//先销毁表格
	// 	$('#cusTable2').bootstrapTable('destroy');
	// 	//初始化表格,动态从服务器加载数据
	// 	$("#cusTable2").bootstrapTable({
	// 		method: "get", //使用get请求到服务器获取数据
	// 		url: "./accReportTotal", //获取数据的地址
	// 		striped: true, //表格显示条纹
	// 		pagination: true, //启动分页
	// 		pageSize: 25, //每页显示的记录数
	// 		pageNumber: 1, //当前第几页
	// 		pageList: [25,50,100,150,200,500], //记录数可选列表
	// 		sidePagination: "server", //表示服务端请求
	// 		paginationFirstText: "首页",
	// 		paginationPreText: "上一页",
	// 		paginationNextText: "下一页",
	// 		paginationLastText: "尾页",
	// 		queryParamsType: "undefined",
	// 		showColumns:true,
	// 		showExport: true,  //是否显示导出按钮
	// 		exportTypes:['excel'],  //导出文件类型
	// 		Icons:'glyphicon-export',
	// 		exportOptions:{
	// 			// ignoreColumn: [0,1],  //忽略某一列的索引
	// 			fileName: '财务统计总表',  //文件名称设置
	// 			worksheetName: '财务统计总表',  //表格工作区名称
	// 			tableName: '财务统计总表',
	// 			excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
	// 			onMsoNumberFormat:function (cell, row, col) {
	// 		       var result = "";
	// 		       if (row > 0 && col == 0)
	// 		           result = "\\@";
	// 		       return result;
	// 		   }
	// 		},
	// 		queryParams: function queryParams(params) { //设置查询参数
	// 			var param = {
	// 				pageNumber: params.pageNumber,
	// 				pageSize: params.pageSize,
	// 				seaTime:$("#seaTime2").val(),
	// 				seaSchool: $("#seaSchool2").val(),
	// 				seaMajor: $("#seaMajor2").val(),
	// 				seaGrade: $("#seaGrade2").val(),
	// 				seaBatch: $("#seaBatch2").val(),
	// 			};
	// 			return param;
	// 		},
	// 		onLoadSuccess: function(res) { //加载成功时执行
	// 			if (111 == res.code) {
	// 				window.location.reload();
	// 			}
	// 			layer.msg("表格加载成功", {time: 1000});
	// 			var tr = '<tr><td colspan="4" class="text-right span-strong">总计</td>'
	// 				   + '<td class="text-center span-strong">' + res.people_num + '</td>'
	// 				   + '<td class="text-center span-strong"></td>'
	// 				   + '<td class="text-center span-strong">' + res.tuition_sum + '</td>'
	// 				   + '<td class="text-center span-strong">' + res.registration_sum + '</td>'
	// 				   + '<td class="text-center span-strong">' + res.material_cost_sum + '</td>'
	// 				   + '<td class="text-center span-strong">' + res.photo_collection_sum + '</td>'
	// 				   + '<td class="text-center span-strong">' + res.total_money_sum + '</td></tr>';
	// 			$("#cusTable2 tbody").append(tr);
	// 			$(".export>.dropdown-menu>li:nth-child(1)>a").html('导出当前');
	// 		},
	// 		onLoadError: function() { //加载失败时执行
	// 			layer.msg("加载数据失败");
	// 		}
	// 	});
	// }

	function getChartData(){
		var time_slot = $("#seaTimePic").val(),time_step = $("#seaTimeStep").val();
		var myChart = echarts.init(document.getElementById('LinePic'));
		var myChart_pie = echarts.init(document.getElementById('PiePic'));
		$(".chartTips").show();
		$.post("./statistics",{time_slot:time_slot,time_step:time_step},function(res){
		    if(res.code == 1){
				var option = {
					title: {text: '财务收支对比'},
			        tooltip: {trigger: 'axis'},
			        legend: {
			            data:['支出','收入']
			        },
			        grid: {left: '3%',right: '4%',bottom: '3%',containLabel: true
			        },
			        toolbox: {
			            show:true,
			            feature: {
			                dataView: {readOnly: true},
			                magicType: {type: ['line','bar']},
			                restore: {},
			                saveAsImage: {}
			            }
			        },
			        xAxis: {
			            type: 'category',
			            boundaryGap: true,
			            data: res.Xdata
			        },
			        yAxis: {
			            type: 'value',
			            axisLabel: {formatter: '￥{value}'}
			        },
			        series: [
			            {
			                name:'支出',
			                type:'line',
			                smooth: true,
			                data:res.redData
			            },
			            {
			                name:'收入',
			                type:'line',
			                smooth: true,
			                data:res.bluData
			            }
			        ]
			    },
				option_pie = {
					title : {
						text: '财务流水组成',
						subtext: '报销退款为支出，其余为收入',
						x:'center'
					},
				    tooltip : {
				        trigger: 'item',
				        formatter: "{a} <br/>{b} : {c} ({d}%)"
				    },
				    legend: {
				        orient: 'vertical',
				        left: 'left',
				        data: ['学员','报销','罚款','退款','其他']
				    },
					toolbox: {
			            show:true,
			            feature: {
			                dataView: {readOnly: true},
			                restore: {},
			                saveAsImage: {}
			            }
			        },
				    series : [
				        {
				            name: '财务流水组成',
				            type: 'pie',
				            radius : '55%',
				            center: ['50%', '60%'],
				            data:res.pieData,
				            itemStyle: {
				                emphasis: {
				                    shadowBlur: 10,
				                    shadowOffsetX: 0,
				                    shadowColor: 'rgba(0, 0, 0, 0.5)'
				                }
				            }
				        }
				    ]
				};
				myChart.setOption(option);
				myChart_pie.setOption(option_pie);
				$(".chartTips").hide();
				layer.msg(res.msg);
			}else{
				layer.msg(res.msg,{anim:6});
			}

		});
	}
	$(function() {
		var seaTime = '';
		//调用函数，初始化表格
		initTable();
		// initTable2();
		//调用函数，初始化图表
		getChartData();
		// getTree();
		layui.use(['form','laydate'], function() {
			var form = layui.form,laydate = layui.laydate;
			laydate.render({elem: '#seaTime',range: true});
			laydate.render({elem: '#seaTimePic',range: true});
  			laydate.render({elem: '#seaTime2',type: 'year'});
			form.on('select(getMajor)',function(data){
				$.post('{:url("Finance/getMajorByPid")}',{pid:data.value},function(res){
					var op = '<option value="" selected>专业</option>';
					for(var i=0;i<res.data.length;i++){
						op += '<option value="'+res.data[i].id+'">'+res.data[i].name+'</option>';
					}
					$("#seaMajor").html(op);
					form.render();
				});
			});

			form.on('select(getMajor2)',function(data){
				$.post('{:url("Finance/getMajorByPid")}',{pid:data.value},function(res){
					var op = '<option value="" selected>专业</option>';
					for(var i=0;i<res.data.length;i++){
						op += '<option value="'+res.data[i].id+'">'+res.data[i].name+'</option>';
					}
					$("#seaMajor2").html(op);
					form.render();
				});
			});

			// samsara 2018-8-1 新增
			// Ajax 改变不同部门时的不同职员
			form.on('select(depart_id)',function(data){
					var depart_id = $('#depart_id').val();
					$.post("{:url('finance/departUser')}",{
							depart_id : depart_id
					},function(res){
							if(res.code == 1){
									var data = res.data;
									var app = '<option value="">咨询师</option>';
									for(var i in data){
											app += '<option value="'+data[i]["id"]+'">'+data[i]["real_name"]+'</option>'
									}
									$('#user_id').html(app);
									form.render();
							}
					})
			})

		});
		//当点击查询按钮的时候执行
		$("#search").bind("click", function(){
			initTable();
		});

		// $("#search2").bind("click", function(){
		// 	initTable2();
		// });

		$("#searchPic").on("click",function(){
			getChartData();
		});

		$(".reportBtns").on('click',function(){
			$(".reportBtns").addClass('btn-success').removeClass('btn-default');
			$(this).addClass('btn-default');
		});
		//日报
		$("#seaTimeDate").on('click',function(){
			if(seaTime != ""){
				seaTime = "";
				$("#seaTime").val("");
				initTable();
			}
		});
		//周报
		$("#seaTimeWeek").on('click',function(){
			var week = getWeekStartDate() + " - " + getWeekEndDate();
			if(week != seaTime){
				seaTime = week;
				$("#seaTime").val(week);
				initTable();
			}
		});
		//月报
		$("#seaTimeMonth").on('click',function(){
			var month = getMonthStartDate() + " - " + getMonthEndDate();
			if(month != seaTime){
				seaTime = month;
				$("#seaTime").val(month);
				initTable();
			}
		});
		//季报
		$("#seaTimeQuarter").on('click',function(){
			var quarter = getQuarterStartDate() + " - " + getQuarterEndDate();
			if(quarter != seaTime){
				seaTime = quarter;
				$("#seaTime").val(quarter);
				initTable();
			}
		});
		//年报
		$("#seaTimeYear").on('click',function(){
			var year = new Date().getYear();
			year += (year < 2000) ? 1900 : 0;
			year = year + "-01-01 - " + year + "-12-31";
			if(year != seaTime){
				seaTime = year;
				$("#seaTime").val(year);
				initTable();
			}
		});
		// 选择咨询师部门
		$('#seaAsk_D').on('click',function(){
			layer.open({
				type:1,
				title:'请选择部门',
				area:['325px','350px'],
				content:$('.TreeBox')
			});
		});
	});

	function getTree(){
	    layui.use(['tree', 'layer'], function(){
	        var layer = layui.layer;

	        $.getJSON("{:url('department/index')}", function(res){
	            if(111 == res.code){
	                window.location.reload();
	            }
	            layui.tree({
	                elem: '#tree'
	                ,nodes: res.data
	                ,click: function(node){
						$('#seaAsk_D').val(node.name);
						$('#seaAsk_D_id').val(node.id);
						layer.closeAll();
	                    nowNode = node;
	                }
	            });
	        });
	    });
	}
	function ExportAll(){
		$('#markShade').show();
		$.post("./ExpotrAllFinanceInfo",{},function(res){
			setTimeout(function(){
				window.open("/upload/excel/download" + {:session("id")} + ".xls");
				$('#markShade').hide();
			},5000);
		});
	}

	// function getSchooleWithPeopleNum(){
    //     $.getJSON("{:url('Finance/getSchooleWithPeopleNum')}", function(res){
    //         if(111 == res.code){
    //             window.location.reload();
    //         }
    //         layui.tree({
    //             elem: '#SchoolTree'
    //             ,nodes: res.data
    //             ,click: function(node){
    //
    //                 nowNode = node;
    //             }
    //         });
    //     });
	// }
</script>
{/block}
